<template>
    <div class="wrapper">
        <swiper :options="swiperOption">
          <swiper-slide v-for="(page, index) of pages" :key="index">
                <div class="listLine">
                    全部类型
                    <span class="options" v-for="item of page" :key="item.id">{{item.movieType}}</span>
                </div>
           </swiper-slide>
        </swiper>
        <swiper :options="swiperOption">
            <swiper-slide   v-for="(page, index) of pages" :key="index">
                <div class="listLine">
                    全部地区
                    <span class="options" v-for="item of page" :key="item.id">{{item.movieRegion}}</span>
                </div>
            </swiper-slide>
        </swiper>
        <swiper :options="swiperOption">
             <swiper-slide  v-for="(page, index) of pages" :key="index">
                <div class="listLine">
                    全部年份
                    <span class="options" v-for="item of page" :key="item.id">{{item.movieYear}}</span>
                </div>
            </swiper-slide>
        </swiper>
    </div>
</template>

<script>
export default {
  name: 'ClassifyList',
  data () {
    return {
      swiperOption: {
        autoplay: false
      },
      detaillist: [{
        id: '0001',
        movieType: '爱情',
        movieRegion: '大陆',
        movieYear: '2020'
      },
      {
        id: '0002',
        movieType: '喜剧',
        movieRegion: '香港',
        movieYear: '2019'
      },
      {
        id: '0003',
        movieType: '动作',
        movieRegion: '台湾',
        movieYear: '2018'
      },
      {
        id: '0004',
        movieType: '科幻',
        movieRegion: '美国',
        movieYear: '2017'
      },
      {
        id: '0005',
        movieType: '恐怖',
        movieRegion: '韩国',
        movieYear: '2016'
      },
      {
        id: '0006',
        movieType: '动画',
        movieRegion: '日本',
        movieYear: '90s'
      },
      {
        id: '0007',
        movieType: '惊悚',
        movieRegion: '欧洲',
        movieYear: '80s'
      },
      {
        id: '0008',
        movieType: '悬疑',
        movieRegion: '印度',
        movieYear: '更早'
      }
      ]
    }
  },
  computed: {
    pages () {
      const pages = []
      this.detaillist.forEach((item, index) => {
        const page = Math.floor(index / 6)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus"  scoped>
 @import '~styles/varibles.styl'
  *{touch-action: none}  //禁止触发默认的手势操作,避免轮播图触发控制台警告
  .wrapper >>> .swiper-container
    height:.68rem
  .wrapper
    height:0
    padding-bottom:30%
    overflow: hidden
    background:pink
    .listLine
      margin:.3rem
      font-size:16px
      .options
        margin-left:.2rem
</style>
